package com.superzqb.asus.superzqbFragment.superzqbSave.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.superzqb.asus.superzqb.R;
import com.superzqb.asus.superzqbUtil.MyItemClicklistener;

import java.util.ArrayList;
import java.util.Map;

/**
 * Created by asus on 2017/3/9.
 */

public class SaveViewAdapter extends RecyclerView.Adapter {
    private Context context;
    private  ArrayList<Map<String, Object>> items;
    private MyItemClicklistener mItemClickListener;
    public SaveViewAdapter(Context c,  ArrayList<Map<String, Object>> i){
        this.context=c;
        this.items=i;
    }
    public void setList( ArrayList<Map<String, Object>> list) {
        this.items = list;
    }
    public void setOnItemClickListener(MyItemClicklistener listener){
        this.mItemClickListener = listener;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new SaveViewHolder(LayoutInflater.from(context).inflate(R.layout.save_item,parent,false),mItemClickListener);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        SaveViewHolder v=(SaveViewHolder) holder;
        Map<String, Object> map=items.get(position);
        v.aimPrice.setText("目标金额(元) "+map.get("aimPrice").toString());
        v.finishPrice.setText("已攒钱(元) "+map.get("finishPrice").toString());
        v.aimFinish.setText("已完成目标"+map.get("aimFinish").toString()+"%");
        v.finishTime.setText("还需要 "+map.get("finishTime").toString()+" 次攒钱");
        v.must.setText("今日需存"+map.get("must").toString()+"(元)");
      /*  v.tv.setText(obj.getName());
        Picasso.with(context).load(new Url().getImg_url() +obj.getImg()).into(v.img);*/
    }

    @Override
    public int getItemCount() {
        return items==null?0:items.size();
    }
}
